# -*- coding: UTF-8 -*-
'''
Created on 09/10/2014

@author: Eduardo Cardeira - Num 6033

Exemplo 5 da Aula Teorica 3

'''
import math

def gerar_cubos(N):
    for i in range(N):
        yield i ** 3

def gerar_quad(N):
    for i in range(N):
        yield i ** 2

def raiz(x, y):
    return math.sqrt(x + y)

def predicado(s):
    return len(s) % 2

def f(x, y):
    return x + math.sqrt(y)

gen = gerar_cubos(5)

print gen.next()
print gen.next()
print gen.next()
print gen.next()
print gen.next()

print
for y in gerar_cubos(5):
    print y

lista = map(raiz, gerar_cubos(5), gerar_quad(5))
i = 0
while i<5:
    print i, " ->", math.sqrt(i ** 3 + i ** 2), " == ", lista[i]
    i += 1
    pass
pass

lista = filter(predicado, ['batata', 'couve', 'cebola', 'repolho'])
print lista

print reduce(f, gerar_cubos(5))
